const { resolve } = require("path");
module.exports = {
  outputDir: "dist",
  publicPath: "/",
  assetsDir: "views/assets",
  parallel: require("os").cpus().length > 1,
  runtimeCompiler: true,
  devServer: {
    disableHostCheck: true,
    host: "127.0.0.1",
    port: 8110,
    proxy: {
      "/api": {
        target: "http://localhost:9999",
        changeOrign: true,
        pathRewrite: {
          "^/api": "",
        },
        logLevel: "debug",
      },
    },
    overlay: {
      //去除eslint报警告
      warning: false,
      error: true,
    },
    // lintOnSave:false,
  },
  lintOnSave:false,
  productionSourceMap: false,
  chainWebpack: (config) => {
    config.resolve.alias
      .set("@", resolve("src/"))
      .set("@assets", resolve("src/assets"))
      .set("@com", resolve("src/components/"))
      .set("@view", resolve("src/views/"))
      .set("@opt", resolve("src/options/"));
    config.module.rules.delete("svg"); //重点:删除默认配置中处理svg,
    config.module
      .rule("svg-sprite-loader")
      .test(/\.svg$/)
      .include.add(resolve("src/assets/icons")) //处理svg目录
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
        symbolId: "icon-[name]",
      });
    config.plugin("html").tap((args) => {
      //设置html标题
      args[0].title = "动态表单组件库";
      return args;
    });
    config.module
      .rule('vue')
      .use('vue-loader')
      .tap(options => {
        options.compilerOptions = {
          ...options.compilerOptions,
          isCustomElement: tag => tag.startsWith('archive-')
        }
        return options
      })
  },
  configureWebpack: {
    devtool: "source-map",
  },
};
